package com.bml.architect.alibaba.web;

import com.bml.architect.alibaba.feign.AccountFeignService;
import com.bml.architect.alibaba.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author: baiml
 * @Title: IndexController
 * @ProjectName: 中台技术平台
 * @Depart 中台研发部
 * @Description:
 * @date: 2021/4/23 12:36
 */
@RestController
@RequestMapping("/index")
public class IndexController {

    //ribbo的实现
    //@Autowired
    //private RestTemplate restTemplate;


//    @RequestMapping("/find/{id}")
//    public R findUserById(@PathVariable("id")Integer userid){
//
//        //ribbon实现
//        String url = "http://my-account/account/findById/"+userid;
//        R result = restTemplate.getForObject(url,R.class);
//        return result;
//
//    }

    //feign的实现

    @Autowired
    private AccountFeignService accountFeignService;

    @RequestMapping("/find/{id}")
    public R findUserById(@PathVariable("id") Integer userid) {

        return accountFeignService.findUserById(userid);
    }


}
